#include<iostream>
using namespace std;
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		char c;
		cin >> c;
		int n;
		cin >> n;
		if (c == 'I') {
			int* arr = new int[n];
			int m = 0;
			for (int j = 0; j < n; j++) {
				cin >> arr[j];
				m += arr[j];
			}
			cout << m / n << endl;
		}
		else if (c == 'C') {
			char* arr = new char[n];
			char ch = 'A';
			for (int j = 0; j < n; j++) {
				cin >> arr[j];
				if (ch < arr[j]) {
					ch = arr[j];
				}
			}
			cout << ch << endl;
		}
		else if (c == 'F') {
			float* arr = new float[n];
			cin >> arr[0];
			float m = arr[0];
			for (int j = 1; j < n; j++) {
				cin >> arr[j];
				if (arr[j] < m) {
					m = arr[j];
				}
			}
			cout << m << endl;
		}
	}
}